package voa;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Util {

	static public class HtmlFilter implements FileFilter {

		public boolean accept(File file) {

			return file.getName().endsWith(".html");
		}

	}

	static public class LrcFilter implements FileFilter {

		public boolean accept(File file) {

			return file.getName().endsWith(".lrc");
		}

	}


	public static void executeCMD(String cmd) {

		Process p;

		// String cmd =
		// "/home/gust/download/kindlegen_linux_2.6_i386_v1.2/./kindlegen /home/gust/tmp/09/SpecialVOA2011-01.opf";

		try {
			// 执行命令
			p = Runtime.getRuntime().exec(cmd);
			// 取得命令结果的输出流
			InputStream fis = p.getInputStream();
			// 用一个读输出流类去读
			InputStreamReader isr = new InputStreamReader(fis);
			// 用缓冲器读行
			BufferedReader br = new BufferedReader(isr);
			String line = null;

			// 直到读完为止
			while ((line = br.readLine()) != null) {
				System.out.println(line);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
